<?php


/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

$_MAMBOTS->registerFunction( 'onDisplayLeftAdminColumnHelpDesk', 'plgHelpDeskOpentickets' );

/**
 * HelpDesk Plugin
 *
 * @package		Joomla
 * @subpackage	JFramework
 * @since 		1.5
 */

	function plgHelpDeskOpentickets( ) {
		global $mainframe, $database;
		$success = false;
	
		// open tix
		$status_query = " AND ( #__helpdesk_tickets.status = '0' ) ";
			  
		$query = "SELECT * FROM #__helpdesk_tickets "
			. " WHERE 1 "
			. $status_query
			;	
		$database->setQuery( $query );
		$total = $database->loadObjectList();
		$total = count($total);
		
		$num = $total;
		
		if ($num == 1) { $text = HelpDeskText::_( 'Open Ticket' ); } else { $text = HelpDeskText::_( 'Open Tickets' ); }
		
		if ($num > 0) {
			$link = JURI_BASE."/administrator/index2.php?option=com_helpdesk&section=tickets&task=list&status=open";
			?>
			<div class='notepi'>	 
				<table class='invisible'>
				  <tr>
					<td>
						<?php 
						?>
					</td>
					<td>
						<?php echo "<a href='".$link."'>$num $text</a>"; ?>
					</td>
				  </tr>
				</table>
			</div>
		<?php }
	
		$success = true;		
		return $success;
		
	}